from django.db import models
from django.utils.translation import ugettext, ugettext_lazy as _

# Create your models here.

class Asset(models.Model):
    device_status = models.ForeignKey('Status')
    idc = models.ForeignKey('IDC', verbose_name=u'IDC机房',null=True, blank=True)
    hostname = models.CharField(max_length=128, blank=True, unique=True)
    sn = models.CharField(u'SN号',max_length=64)
    nipaddr = models.GenericIPAddressField(u'ip地址',blank=True,null=True)
    #netmask = models.GenericIPAddressField(u'子网掩码',blank=True,null=True)
    oipaddr = models.GenericIPAddressField(u'外网ip',blank=True,null=True)
    #nipaddr = models.GenericIPAddressField(u'内网ip',blank=True,null=True)
    model = models.CharField(u'型号',max_length=128,null=True, blank=True )
    cpu = models.IntegerField(
	_("CPU")
    )
    mem = models.IntegerField(
	_("内存")
    )
    disk_storage_size = models.IntegerField(
        _("存储"),
    )
    disk_root_storage_size = models.IntegerField(
        _("系统存储")
    )
    bandwidth = models.IntegerField(
        _("带宽"),
        default=0
    )
    create_at = models.DateTimeField(blank=True, auto_now_add=True)
    update_at = models.DateTimeField(blank=True, auto_now=True)
    class Meta:
        verbose_name = '服务器'
        verbose_name_plural = '服务器'
    def __str__(self):
        return self.sn + self.hostname


class Status(models.Model):
   name = models.CharField(max_length=64)
   memo = models.TextField(u'备注', null=True, blank=True)
   class Meta:
        verbose_name = '状态'
        verbose_name_plural = '状态'
   def __str__(self):
        return self.name


class IDC(models.Model):
    name = models.CharField(u'机房english',max_length=30)
    display_name = models.CharField(u'中文显示名',max_length=32,default=None)
    region = models.CharField(u'区域',max_length=64,default=None)
    memo = models.CharField(u'备注',max_length=64,default=None,blank=True)
    def __str__(self):
        return self.name
    class Meta:
        verbose_name = '机房'
        verbose_name_plural = "机房"
